unit ufSF_Status;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, ufCustomSetupFrame, Vcl.ExtCtrls, Vcl.Imaging.pngimage,
  Vcl.Buttons, Vcl.StdCtrls, Vcl.ComCtrls;

type
  TfSF_Status = class(TfCustomSetupFrame)
    iTop_Stopped: TImage;
    pHeader: TPanel;
    Label3: TLabel;
    btServerPause: TSpeedButton;
    btServerResume: TSpeedButton;
    Panel4: TPanel;
    Shape8: TShape;
    Label9: TLabel;
    Image2: TImage;
    lwProviders: TListView;
    Shape2: TShape;
    btInfo: TLabel;
    procedure btServerPauseClick(Sender: TObject);
    procedure btServerResumeClick(Sender: TObject);
    procedure btInfoMouseEnter(Sender: TObject);
    procedure btInfoMouseLeave(Sender: TObject);
  private
    { Private declarations }
  public
    procedure Prepare(); override;
    procedure BeforClose(); override;
    procedure Refresh(); override;
    procedure Activate(); override;
  end;

var
  fSF_Status: TfSF_Status;

implementation

{$R *.dfm}

uses System.UITypes, srvMainForm, uformDataModule;


{ TfSF_Status }

procedure TfSF_Status.Activate;
begin
  inherited;

end;

procedure TfSF_Status.BeforClose;
begin
  inherited;

end;

procedure TfSF_Status.btInfoMouseEnter(Sender: TObject);
begin
  (Sender as TLabel).Font.Style:= (Sender as TLabel).Font.Style + [fsUnderline];
end;

procedure TfSF_Status.btInfoMouseLeave(Sender: TObject);
begin
  (Sender as TLabel).Font.Style:= (Sender as TLabel).Font.Style - [fsUnderline];
end;

procedure TfSF_Status.btServerPauseClick(Sender: TObject);
begin
  formDataModule.Server.Stop;
  Refresh();
end;

procedure TfSF_Status.btServerResumeClick(Sender: TObject);
begin
  formDataModule.Server.Start;
  Refresh();
end;

procedure TfSF_Status.Prepare;
begin
  inherited;
  Refresh();
end;

procedure TfSF_Status.Refresh;
begin
  inherited;
  if formDataModule.Server.Started then begin
    btServerPause.Enabled:= True;
    btServerResume.Enabled:= False;

    frmMain.iTop.Picture.Assign(iTop.Picture);
  end else begin
    btServerPause.Enabled:= False;
    btServerResume.Enabled:= True;

    frmMain.iTop.Picture.Assign(iTop_Stopped.Picture);
  end;
end;

end.
